public final class Cache {
	private final NodeSub emptyNodeSub;
	private final int initialCapacity;
	private final HashTable hashTable;
	private final Queue queue;
	private int capacity;

	public NodeSub get(long key) {
		NodeSub nodeSub = (NodeSub) hashTable.getKey(key);
		if (nodeSub != null) {
			queue.insertBack(nodeSub);
		}
		return nodeSub;
	}

	public void put(NodeSub nodeSub, long key) {
		try {
			if (capacity == 0) {
				NodeSub nodeSub_1 = queue.popFront();
				nodeSub_1.unlink();
				nodeSub_1.unlinkSub();
				if (nodeSub_1 == emptyNodeSub) {
					NodeSub nodeSub_2 = queue.popFront();
					nodeSub_2.unlink();
					nodeSub_2.unlinkSub();
				}
			} else {
				capacity--;
			}
			hashTable.remove(nodeSub, key);
			queue.insertBack(nodeSub);
			return;
		} catch (RuntimeException runtimeexception) {
			Signlink.reporterror("47547, " + nodeSub + ", " + key + ", " + (byte) 2 + ", "
			+ runtimeexception.toString());
		}
		throw new RuntimeException();
	}

	public void clear() {
		do {
			NodeSub nodeSub = queue.popFront();
			if (nodeSub != null) {
				nodeSub.unlink();
				nodeSub.unlinkSub();
			} else {
				capacity = initialCapacity;
				return;
			}
		} while (true);
	}

	public Cache(int size) {
		emptyNodeSub = new NodeSub();
		queue = new Queue();
		initialCapacity = size;
		capacity = size;
		hashTable = new HashTable();
	}
}
